package com.imoocdl.utils;

import java.util.Random;

/**
 * Created by pc on 2018/3/31.
 */
public class KeyUtil {
    /**
     * 生成唯一主键
     * 格式:时间+随机数
     * synchronized 锁 防止重复
     * @return
     */
    public static synchronized String genUniqueKey(){
        Random random = new Random();
        //生成六位随机数
      Integer number =   random.nextInt(900000)+100000;
      return System.currentTimeMillis() + String.valueOf(number);
    }
}
